<template>
    <section>
        <h1>数值介绍（点击图标查看）</h1>
        <div class="token-list">
            <div v-for="option in tokenIntroList" :key="option.type" class="token-item"
                :class="{ chosen: chosenToken?.type === option.type }" @click="chosenToken = option">
                <Token :type="option.type" size="min(36px,4vw)"></Token>
                <div class="token-name">{{ option.name }}</div>
            </div>
        </div>
        <div class="token-intro">
            <header>
                <h2>{{ chosenToken.name }}：</h2>
                <Token :type="chosenToken.type" :sub="getTokenSub(chosenToken.type)" sup='?' size="min(28px,2vw)">
                </Token>（正面）
                <Token :type="chosenToken.type" :sub="getTokenSub(chosenToken.type)" sup='?' back-side
                    size="min(28px,2vw)"></Token>
                （背面）
            </header>
            <p>{{ chosenToken.intro }}</p>
        </div>
    </section>
</template>

<script lang="ts" setup>
import Token from '@/components/game/token.vue';
import { tokenIntroList } from '@/game/intro/token';
import { tokenIntroItem } from '@/types/game/token';
import { ref } from 'vue';
const chosenToken = ref<tokenIntroItem>(tokenIntroList[0]);
const getTokenSub = (tokenType: string) => ['fate', 'development', 'mobilization', 'military'].includes(tokenType) ? '?' : null;
</script>

<style scoped>
section{
    padding: 1vh 0.5vw;
    background-color: rgba(0, 0, 0, 0.5);
}
.token-list {
    margin-top: 1vh;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
}

.token-item {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5vh 0.5vw;
    border-radius: min(0.5vw, 5px);
    transition: 0.2s;
}

.token-name {
    margin-top: 5px;
    font-size: min(20px, 3vw);
}

.token-intro {
    width: 100%;
    padding: 0.5vh 0.5vw;
}

.token-intro header {
    display: flex;
    align-items: center;
    margin-bottom: 1vh;
}

.token-item:hover,
.token-item.chosen,
.token-intro {
    background-color: gray;
    border-radius: 5px;
}

p,
h2,
header {
    font-size: min(20px, 2vw);
}
</style>